package com.zhentao.feign;

//import com.zhentao.api.schedule.ScheduleClientApi;

import com.zhentao.api.schedule.ScheduleClientApi;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.schedule.dto.TaskDto;
import com.zhentao.service.TaskInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ScheduleClient implements ScheduleClientApi {
    @Autowired
    private TaskInfoService taskInfoService;

    @PostMapping("/api/v1/task/add")
    public ResponseResult addTask(@RequestBody TaskDto dto) {
        return ResponseResult.okResult(taskInfoService.addTask(dto));
    }

    @GetMapping("/api/v1/task/{taskId}")
    public ResponseResult canceTask(@PathVariable("taskId") Long taskId) {
        return ResponseResult.okResult(taskInfoService.canceTask(taskId));
    }

    @Override
    @GetMapping("/api/v1/task/{taskId}/{priority}")
    public ResponseResult poll(@PathVariable("taskId") Integer type, @PathVariable("priority") Integer priority) {
        return ResponseResult.okResult(taskInfoService.poll(type, priority));
    }
}